package com.vip.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tianlianyin
 * @Date 2024/11/9
 */
@Slf4j
@SpringBootApplication
@RestController
@ComponentScan("com.vip.**")
@EnableScheduling // 开启定时任务
public class Application {
    /* 解决druid 日志报错：discard long time none received connection:xxx */
    static {
        System.setProperty("druid.mysql.usePingMethod", "false");
    }

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(Application.class, args);
        ConfigurableEnvironment environment = run.getEnvironment();
        String contextPath = environment.getProperty("server.servlet.context-path");
        Integer port = environment.getProperty("server.port", Integer.class);
        log.info("""
                                                
                        ----------------------------------------------------------
                        Application is running! Access URLs:
                        Local:    http://127.0.0.1:{}{}
                        Doc:      http://127.0.0.1:{}{}/doc.html
                        druid:    http://127.0.0.1:{}{}/druid
                        ----------------------------------------------------------
                        """,
                port, contextPath, port, contextPath, port, contextPath);
    }

    @GetMapping
    public String hello() {
        return "hello";
    }
}
